/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package GUIComponents.weeklyComponents;

import MainClasses.*;
import java.util.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

/**
 *
 * @author andrewcutler
 */
public class WeeklyViewPanel extends JScrollPane{

    private JPanel panel;
    private ArrayList<WeeklyClassPanel> panels;
    private WeeklyHeaderPanel headerPanel;
    
    public WeeklyViewPanel(CourseManager manager)
    {
        super(new JPanel());
        
        ArrayList<Course> courses = manager.getCourses();
        this.setName("Weekly View");        
        panel = (JPanel) super.getViewport().getView();        
        
        panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
        
        panels = new ArrayList<WeeklyClassPanel> ();        
        
        panel.setBorder(BorderFactory.createLineBorder(Color.black));
        headerPanel = new WeeklyHeaderPanel();
        panel.add(headerPanel);
        WeeklyClassPanel currentPanel = null;
        for(Course c : courses)
        {            
            currentPanel = new WeeklyClassPanel(c);
            currentPanel.setBorder(BorderFactory.createLineBorder(Color.black));
            
            panels.add(currentPanel);
            panel.add(currentPanel);
        }
    }
    
    
    public void reset()
    {
        //headerPanel.reset();
        for(WeeklyClassPanel p : panels)
        {
            p.reset();
        }
    }
    
    private class WeeklyHeaderPanel extends JPanel
    {
        public WeeklyHeaderPanel()
        {
            this.setLayout(new GridLayout(1, 7));
            
            for(int i = 0; i<7; i++)
            {
                this.add(new WeeklyHeaderDayPanel(i));
            }
        }
        
        public void reset()
        {
            
        }
    }
    
    private class WeeklyHeaderDayPanel extends JPanel
    {
        public WeeklyHeaderDayPanel(int i)
        {
            
            this.setBorder(BorderFactory.createLineBorder(Color.black));
            this.add(new JLabel(main.getCurrentDate(i).toString(MyDate.FORMAT_1, "-")));
        }
    }
    
}
